package com.iretailer.report.analyze.flow.device;

import com.alibaba.fastjson.JSON;
import com.iretailer.report.analyze.annotation.AnalyzeClass;
import com.iretailer.report.analyze.commonModel.PassengerFlowModel;
import com.iretailer.report.analyze.commonUtil.ResponeResultType;
import com.iretailer.report.analyze.flow.Flow;
import com.iretailer.report.util.StringUtil;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Auther: xjw
 * @Date: 2019/5/9 15:34
 * @Description:
 */
@AnalyzeClass
@Component
public class CommonFtp extends Flow {

    @Value("${netty.path.commonftp}")
    private String commonftp;

    @Override
    public PassengerFlowModel transformation(String context, Map<String, Object> paramsMap) {
        PassengerFlowModel result = JSON.parseObject(context, PassengerFlowModel.class);
        result.setChannelCloseType(ResponeResultType.CFLType.CLOSE_ON_FAILURE);
        return result;
    }

    @Override
    public String[] analyzePath() {
        if (StringUtil.notEmpty(commonftp)) {
            return commonftp.split(",");
        } else {
            return new String[]{"/ftp", "/nec1010"};
        }
    }
}
